'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const db = uniCloud.database();
	// 获取 `user` 集合的引用
	const collection = db.collection('hbcache');
	var data = await collection.where({
		"cacheid":event.cacheid
	}).get()
	let result = false
	if(data.data.length == 0){
		// 新增
		result  = await collection.add(event)
	}else{
		//更新
		result = await collection.where({
			"cacheid":event.cacheid
		}).update(event)
	}
	//返回数据给客户端
	return result 
};
